<template>
  <a-modal
    :visible.sync="showOperationDetail"
    @cancel="closeOperationDetail"
    title="详情"
    cancelText="关闭"
    :width="modalWidth"
    destroyOnClose
    :confirmLoading="confirmLoading"
    :bodyStyle="tstyle">
    <template slot="footer">
      <a-button key="取消" @click="closeOperationDetail">关闭</a-button>
    </template>
    <a-card :title='"工序号："+ woNo + "|" +processCode' style="margin-top: -15px;" :bordered="true">
      <template>
        <!-- current指定当前步骤，从 0 开始记数 -->
        <a-steps :current="bgStatus" labelPlacement="vertical">
          <a-step title="创建"></a-step>
          <a-step title="生产中"></a-step>
          <a-step title="完工入库"></a-step>
        </a-steps>
      </template>
      <a slot="extra">国网推送状态：
        <a-button v-if="dataSourceDetail.ioflag==='0'" type="primary">
          已推送
        </a-button>
      </a>
    </a-card>
    <a-card title="基本信息" style="margin-top: 10px;">
      <a-row :span="24">
        <a-col :span="8">
          采购方总部编码：{{ filterDictText(this.purchaserHqCodeDictOptions, dataSourceDetail.purchaserHqCode) }}
        </a-col>
        <a-col :span="8">
          供应商编码：{{ dataSourceDetail.supplierCode }}
        </a-col>
        <a-col :span="8">
          供应商名称：{{ dataSourceDetail.supplierName }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          生产订单编号：{{ dataSourceDetail.ipoNo }}
        </a-col>
        <a-col :span="8">
          设备编号：{{ dataSourceDetail.deviceNo }}
        </a-col>
        <a-col :span="8">
          生产批次号：{{ dataSourceDetail.productBatchNo }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          产品型号：{{ dataSourceDetail.productionModel }}
        </a-col>
        <a-col :span="8">
          生产对象名称：{{ dataSourceDetail.manufacturedName }}
        </a-col>
        <a-col :span="8">
          工序名称：{{ dataSourceDetail.processName }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          品类编码：{{ filterDictText(this.categoryCodeDictOptions, dataSourceDetail.categoryCode )}}
        </a-col>
        <a-col :span="8">
          种类编码：{{ filterDictText(this.subclassCodeDictOptions, dataSourceDetail.subclassCode) }}
        </a-col>
        <a-col :span="8">
          工序编码：{{ dataSourceDetail.processCode }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          生产工艺路线编码：{{ dataSourceDetail.processNo }}
        </a-col>
        <a-col :span="8">
          生产车间id：{{ dataSourceDetail.workshopId }}
        </a-col>
        <a-col :span="8">
          生产车间编码：{{ dataSourceDetail.workshopCode }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          生产车间名称：{{ dataSourceDetail.workshopName }}
        </a-col>
        <a-col :span="8">
          生产工单编号：{{ dataSourceDetail.woNo }}
        </a-col>
        <a-col :span="8">
          实物ID：{{ dataSourceDetail.productId }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          数据来源：{{ filterDictText(this.dataSourceDictOptions, dataSourceDetail.dataSource) }}
        </a-col>
        <a-col :span="8">
          来源数据创建时间：{{ dataSourceDetail.dataSourceCreateTime }}
        </a-col>
        <a-col :span="8">
          计划开始时间：{{ dataSourceDetail.planStartTime }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          计划结束时间：{{ dataSourceDetail.planEndTime }}
        </a-col>
        <a-col :span="8">
          实际开始时间：{{ dataSourceDetail.actualStartDate }}
        </a-col>
        <a-col :span="8">
          实际结束时间：{{ dataSourceDetail.actualFinishDate }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          订单状态：{{ filterDictText(this.woStatusDictOptions, dataSourceDetail.orderStatus) }}
        </a-col>
        <a-col :span="8">
          客户所属省份：{{ dataSourceDetail.buyerProvince }}
        </a-col>
        <a-col :span="8">
          数据拥有方：{{ dataSourceDetail.ownerId }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          数据可见方：{{ dataSourceDetail.openId }}
        </a-col>
        <a-col :span="8">
          报告批注：{{ dataSourceDetail.comment }}
        </a-col>
        <a-col :span="8">
          逻辑删除：{{ filterDictText(this.isDeletedDictOptions, dataSourceDetail.isDeleted) }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          更新时间：{{ dataSourceDetail.modifyTime }}
        </a-col>
      </a-row>
    </a-card>
    <a-card title="数据评价详情" style="margin-top: 10px;">
      <p>
        <span style="color: blue;">链接审核：</span>
        <span>{{ linkMessage }}</span>
      </p>
      <p>
        <span style="color: blue;">日期审核：</span>
        <span>{{ dateMessage }}</span>
      </p>
    </a-card>
  </a-modal>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ViserChartDemo from '../../../../jeecg/report/ViserChartDemo'
  import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'EipOperationDetail',
    mixins: [JeecgListMixin],
    components: { ViserChartDemo },
    props: {
      dataSourceDetail: {
        type: Object,
        default: false
      }
    },
    data() {
      //详细信息表头
      return {
        showOperationDetail: true,     //详情页面
        linkMessage: '',
        dateMessage: '',
        woNo: '',                       //工单号
        processCode: '',                //工序号
        bgStatus: 0,                    //报工状态
        purchaserHqCodeDictOptions: [],
        categoryCodeDictOptions: [],
        subclassCodeDictOptions: [],
        woStatusDictOptions: [],
        dataSourceDictOptions: [],
        isDeletedDictOptions: [],
        modalWidth: '75%',
        tstyle: {
          'height': '700px',
          'overflow': 'auto'
        },
        loading: false,
        confirmLoading: false
      }
    }
    ,
    methods: {
      initDictConfig() {
        initDictOptions('purchaserHqCode').then((res) => {
          if (res.success) {
            this.purchaserHqCodeDictOptions = res.result
          }
        })
        initDictOptions('categoryCode').then((res) => {
          if (res.success) {
            this.categoryCodeDictOptions = res.result
          }
        })
        initDictOptions('subclassCode').then((res) => {
          if (res.success) {
            this.subclassCodeDictOptions = res.result
          }
        })
        initDictOptions('woStatus').then((res) => {
          if (res.success) {
            this.woStatusDictOptions = res.result
          }
        })
        initDictOptions('dataSource').then((res) => {
          if (res.success) {
            this.dataSourceDictOptions = res.result
          }
        })
        initDictOptions('isDeleted').then((res) => {
          if (res.success) {
            this.isDeletedDictOptions = res.result
          }
        })
      },
      closeOperationDetail() {//详细信息是否关闭
        this.$emit('close')
      },
      loadData() {
        let operation = this.dataSourceDetail
        this.woNo = operation.woNo
        this.processCode = operation.processCode
        if (operation.actualStartDate === null && operation.actualFinishDate === null) {
          this.bgStatus = 0
        }
        if (operation.actualStartDate !== null && operation.actualFinishDate === null) {
          this.bgStatus = 1
        }
        if (operation.actualStartDate !== null && operation.actualFinishDate !== null) {
          this.bgStatus = 2
        }
        this.linkMessage = '【已链接上一级订单】。'
        this.dateMessage = ''
        let reg = new RegExp('"', 'g')
        let messages = JSON.stringify(operation.remark1).replace(reg, '').split(';')
        for (let message in messages) {
          if (messages[message] === '10001') {
            this.linkMessage = '【未链接至上一级订单】。'
          }
          if (messages[message] === '10003') {
            this.dateMessage = '【实际完成时间】大于【计划完成时间】，超期报工！'
          }
          if (messages[message] === '10004') {
            this.dateMessage ='【实际完成时间】小于【计划完成时间】，提前报工！'
          }
          if (messages[message] === '10005') {
            this.dateMessage = '【实际完成时间】等于【计划完成时间】，按期报工！'
          }
        }
      }
    }
  }
</script>

<style scoped>

</style>